﻿using Prism.Ioc;
using SmartParking.Client.BaseModule;
using SmartParking.Client.BLL;
using SmartParking.Client.DAL;
using SmartParking.Client.IBLL;
using SmartParking.Client.IDAL;
using SmartParking.Client.MainModule;
using SmartParking.Client.Start.Views;
using System.Configuration;
using System.Data;
using System.Windows;
using System.Windows.Threading;

namespace SmartParking.Client.Start;

/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : PrismApplication
{
    protected override Window CreateShell()
    {
        return Container.Resolve<MainWindow>();
    }
    protected override void InitializeShell(Window shell)
    {
        if (Container.Resolve<LoginView>().ShowDialog() == false) {
            Application.Current?.Shutdown();
        }
        else
            base.InitializeShell(shell);
    }

    protected override void RegisterTypes(IContainerRegistry containerRegistry)
    {
        containerRegistry.Register<Dispatcher>(() => Application.Current.Dispatcher);

        containerRegistry.Register<ILoginDAL, LoginDAL>();
        containerRegistry.Register<ILoginBLL, LoginBLL>();

        containerRegistry.Register<IUserDal, UserDal>();
        containerRegistry.Register<IUserBLL, UserBLL>();
    }

    protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
    {
        // 可以自动扫描
        moduleCatalog.AddModule<MainModule.MainModule>();
        moduleCatalog.AddModule<BaseInfoModule>();
    }
}

